<template>
  <div id="app">


    <template>
      <el-select v-model="status" placeholder="请选择">
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
        </el-option>
      </el-select>
    </template>

    <template>
      <el-table
          :data="OrderList"
          style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="订单号">
                <span>{{ props.row.pay_code }}</span>
              </el-form-item>
              <el-form-item label="用户ID">
                <span>{{ props.row.user_id }}</span>
              </el-form-item>
              <el-form-item label="商品 ID">
                <span>{{ props.row.id }}</span>
              </el-form-item>
              <el-form-item label="下单时间">
                <span>{{ props.row.create_time }}</span>
              </el-form-item>
              <el-form-item label="商品分类">
                <span>{{ props.row.status }}</span>
              </el-form-item>
              <el-form-item label="用户头像">
<!--                <span>{{ props.row.address }}</span>-->
<!--                <img src="{{ props.row.head_portrait }}" class="image">-->


                  <el-image
                      style="width: 50px; height: 50px"
                      :src="props.row.head_portrait"
                      :preview-src-list="props.row.head_portrait">
                  </el-image>





              </el-form-item>
<!--              <el-form-item label="商品描述">-->
<!--                <span>{{ props.row.desc }}</span>-->
<!--              </el-form-item>-->
            </el-form>
          </template>
        </el-table-column>
        <el-table-column
            label="卖家 ID"
            width="150px"
            prop="user_id">
        </el-table-column>
        <el-table-column
            label="买家姓名"
            width="150px"
            prop="name">
        </el-table-column>
        <el-table-column
            label="商品名称"
            width="150px"
            prop="order_product[0].product_name">
        </el-table-column>
        <el-table-column
            label="下单时间"
            width="250px"
            prop="create_time">
        </el-table-column>
      </el-table>
    </template>




    <div class="block">
      <el-pagination
          @current-change="handleCurrentChange"
          layout="prev, pager, next"
          :total="1000">
      </el-pagination>
    </div>





  </div>
</template>

<script>
import login from "@/components/login";

export default {
  data() {
    return {
      OrderList: [],
      options: [{
        value: 0,
        label: '待支付'
      }, {
        value: 1,
        label: '待发货'
      }, {
        value: 2,
        label: '待收货'
      }, {
        value: 5,
        label: '已经取消'
      }],
      status: 0,
      page: 1,
    }
  },
  created() {
    this.getOrderList();
  },
  methods: {
    // 获取订单列表
    async getOrderList() {
      await this.$http.post("/Admin/orderList",{
        page: this.page,
        limit: 10,
        status: this.status,
      }).then(res =>{
        this.OrderList = res.data.data;
        console.log(this.OrderList)
      }).catch(err => {
        console.log(err)
      })
    },
    // 获取订单详情
    async getOrderInfo(index) {
      console.log("getOrderInfo index: " + index)
      await this.$http.post("/admin/orderInfo",{
        // id: index
      }).then(res =>{
        console.log(res)
      }).catch(err => {
        console.log(err)
      })
    },


    // 操作当前页面
    handleCurrentChange(val) {
      // console.log(val)
      this.page = val;
    },
  },

  watch: {
    status: function () {
      this.getOrderList();
    },
    page: function () {
      this.getOrderList();
    },
  }





}

</script>

<style lang="less" scoped>




.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}





</style>
